package io.openmessaging;

import java.nio.ByteBuffer;

/**
 * 消息
 *
 * @author cuijd    2021/9/28 12:30
 */
public class Message {
    public final Topic topic;
    public final int queueId;
    public final long offset;
    public ByteBuffer data;

    public Message(Topic topic, int queueId, long offset, ByteBuffer data) {
        this.topic = topic;
        this.queueId = queueId;
        this.offset = offset;
        this.data = data;
    }

    @Override
    public String toString() {
        return " " + topic.name + "_" + queueId + "_" + offset + "_" + data.remaining();
    }

    public Message clone() {
        return new Message(topic, queueId, offset, data.slice());
    }
}
